//****************************************************************************
// File:    Card.cpp
// Author:  Dr. Thomas C. Bressoud
// Date:    February 8, 2008
// Class:   CS 173-01, Professor Bressoud
// Purpose: Implementation file for the Card class, defining a single card
//          with a domain consisting of a rank and a suit.  Operations include
//          creation and acessing rank and suit.
// Input:   NA
// Output:  NA
//****************************************************************************
#include <iostream>
#include <cassert>
using namespace std;

#include "Card.h"

Card::Card()
//============================================================================
// Purpose: Default constructor, initializing a card to the ace of spaces.
//
// Precondition:  None
// Postcondition: Created Card object with valid rank (ace) and suit (spades)
//============================================================================
{
  mySuit = SPADES;
  myRank = 1;
}

Card::Card(int r, Suit s)
//============================================================================
// Purpose: Constructor, initializing a card to the given rank r and suit s.
//
// Precondition:  1 <= r <= 13 && s in {SPADES, HEARTS, DIAMONDS, CLUBS}
// Postcondition: Created Card object with rank r, and suit s
//============================================================================
{
  assert(r >= 1 && r <= 13);
  assert((int)s >= 0 && (int)s <= NUMSUIT);
  
  mySuit = s;
  myRank = r;
}

int Card::getRank() const{
	return myRank;
}

Card::Suit Card::getSuit() const{
	return mySuit;
}

void Card::print() const{
	cout << toString();
}

string Card::toString() const{
	const string CARD_FACES[] =  {"A", "2", "3", "4", "5", "6", "7"
	                                    , "8", "9", "10", "J", "Q", "K"};
	const string CARD_SUITS[] = {"S", "H", "C", "D"};
	string tmp;
	tmp = CARD_FACES[myRank-1];
	tmp += CARD_SUITS[mySuit];
	return (tmp);
}
